Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interfaces/builtin/opengl: enable parsing of nvidia driver information files #14893

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

jocado
Copy link
Contributor

@jocado jocado commented Dec 23, 2024

interfaces/opengl: Enable parsing of nvidia driver information files

Some nvidia hardware companion utilities required access to driver information in order to operate properly, for example nvidia-persistenced. This enables read only access to those files.

Example file content:

/proc/driver/nvidia/gpus/0000\:70\:00.0/information

Model: 		 NVIDIA L4
IRQ:   		 16
GPU UUID: 	 GPU-3291dfa4-fcc4-0110-615b-c894a0d7c689
Video BIOS: 	 95.04.65.00.13
Bus Type: 	 PCIe
DMA Size: 	 47 bits
DMA Mask: 	 0x7fffffffffff
Bus Location: 	 0000:70:00.0
Device Minor: 	 0
GPU Excluded:	 No

/proc/driver/nvidia/capabilities/mig/monitor

DeviceFileMinor: 2
DeviceFileMode: 292
DeviceFileModify: 1

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@03a578a). Learn more about missing BASE report.
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #14893   +/-   ##
=========================================
  Coverage          ?   78.27%           
=========================================
  Files             ?     1158           
  Lines             ?   153471           
  Branches          ?        0           
=========================================
  Hits              ?   120122           
  Misses            ?    25944           
  Partials          ?     7405           
Flag Coverage Δ
unittests 78.27% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bboozzoo bboozzoo requested a review from zyga January 8, 2025 09:29
@@ -103,6 +103,8 @@ const openglConnectedPlugAppArmor = `
# nvidia
/etc/vdpau_wrapper.cfg r,
@{PROC}/driver/nvidia/params r,
@{PROC}/driver/nvidia/gpus/[0-9]*:[0-9]*:[0-9]*.[0-9]*/information r,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the 'bus location' known to be only pci-like, or would it make sense to use more generic pattern here?

Suggested change
@{PROC}/driver/nvidia/gpus/[0-9]*:[0-9]*:[0-9]*.[0-9]*/information r,
@{PROC}/driver/nvidia/gpus/*/information r,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I'm not sure.

I was going for the safest default, but I would be in favour of switching to a more generic pattern too for simplicity/compatibility if there is no objection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to the wildcard. I can revert if anyone objects.

@@ -103,6 +103,8 @@ const openglConnectedPlugAppArmor = `
# nvidia
/etc/vdpau_wrapper.cfg r,
@{PROC}/driver/nvidia/params r,
@{PROC}/driver/nvidia/gpus/[0-9]*:[0-9]*:[0-9]*.[0-9]*/information r,
@{PROC}/driver/nvidia/capabilities/mig/monitor r,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, what other files are present there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my system I see:

[zyga@ciri ~]$ find /proc/driver/nvidia/ -ls
4026532876      0 dr-xr-xr-x  11 root     root            0 sty  8 08:14 /proc/driver/nvidia/
4026532887      0 dr-xr-xr-x   3 root     root            0 sty  8 08:14 /proc/driver/nvidia/gpus
4026532904      0 dr-xr-xr-x   5 root     root            0 sty  8 08:14 /proc/driver/nvidia/gpus/0000:02:00.0
4026532907      0 -r--r--r--   1 root     root            0 sty  8 11:07 /proc/driver/nvidia/gpus/0000:02:00.0/power
4026532906      0 -rw-r--r--   1 root     root            0 sty  8 11:07 /proc/driver/nvidia/gpus/0000:02:00.0/registry
4026532905      0 -r--r--r--   1 root     root            0 sty  8 11:07 /proc/driver/nvidia/gpus/0000:02:00.0/information
4026532878      0 -r--r--r--   1 root     root            0 sty  8 08:14 /proc/driver/nvidia/params
4026532884      0 dr-xr-xr-x   3 root     root            0 sty  8 11:07 /proc/driver/nvidia/patches
4026532885      0 -r--r--r--   1 root     root            0 sty  8 11:07 /proc/driver/nvidia/patches/README
4026532881      0 -rw-r--r--   1 root     root            0 sty  8 08:36 /proc/driver/nvidia/suspend
4026532886      0 -r--r--r--   1 root     root            0 sty  8 11:07 /proc/driver/nvidia/version
4026532879      0 -rw-r--r--   1 root     root            0 sty  8 11:07 /proc/driver/nvidia/registry
4026532882      0 dr-xr-xr-x   3 root     root            0 sty  8 11:07 /proc/driver/nvidia/warnings
4026532883      0 -r--r--r--   1 root     root            0 sty  8 11:07 /proc/driver/nvidia/warnings/README
4026532888      0 dr-xr-xr-x   5 root     root            0 sty  8 08:15 /proc/driver/nvidia/capabilities
4026532900      0 dr-xr-xr-x   4 root     root            0 sty  8 08:15 /proc/driver/nvidia/capabilities/mig
4026532901      0 -r--r--r--   1 root     root            0 sty  8 08:15 /proc/driver/nvidia/capabilities/mig/config
4026532902      0 -r--r--r--   1 root     root            0 sty  8 08:15 /proc/driver/nvidia/capabilities/mig/monitor
4026533128      0 dr-xr-xr-x   3 root     root            0 sty  8 11:07 /proc/driver/nvidia/capabilities/gpu0
4026533129      0 dr-xr-xr-x   2 root     root            0 sty  8 11:07 /proc/driver/nvidia/capabilities/gpu0/mig
4026532903      0 -r--r--r--   1 root     root            0 sty  8 11:07 /proc/driver/nvidia/capabilities/fabric-imex-mgmt
4026532880      0 -rw-r--r--   1 root     root            0 sty  8 11:07 /proc/driver/nvidia/suspend_depth

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[zyga@ciri ~]$ cat /proc/driver/nvidia/patches/README
The NVIDIA graphics driver's kernel interface files can be
patched to improve compatibility with new Linux kernels or to
fix bugs in these files. When applied, each official patch
provides a short text file with a short description of itself
in this directory.
[zyga@ciri ~]$ cat /proc/driver/nvidia/warnings/README
The NVIDIA graphics driver tries to detect potential problems
with the host system and warns about them using the system's
logging mechanisms. Important warning message are also logged
to dedicated text files in this directory.

Copy link
Contributor

@zyga zyga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite know what the mig/monitor file is for. Looking on my system I see:

[zyga@ciri ~]$ cat /proc/driver/nvidia/capabilities/mig/monitor
DeviceFileMinor: 2
DeviceFileMode: 292
DeviceFileModify: 1

The sister capabilities/mig/config file, which is not requested by this pull request, says:

[zyga@ciri ~]$ cat /proc/driver/nvidia/capabilities/mig/config
DeviceFileMinor: 1
DeviceFileMode: 256
DeviceFileModify: 1

I think it's probably safe to allow both, but I'm also happy to +1 this as-is.

@jocado
Copy link
Contributor Author

jocado commented Jan 8, 2025

My primary goal here it to enable nvidia-persistenced to run, so I've simply added the bare minimum in order to achieve that.

I'm not not overly familiar with MIG [ Multi-Instance GPU ], or how to configure it, but there is some info here about the capabilities files: https://docs.nvidia.com/datacenter/tesla/mig-user-guide/index.html#dev-based-nvidia-capabilities

It seems clear from the doc that to make use of MIG, granting read access to the capabilities files is not enough by itself, although that is not what I'm trying to do here. If a use case for MIG comes up here in the future, I may try and enhance the access further at that time, and presumably at that point I would be in position to test it properly too [ which currently I'm not ].

@jocado jocado force-pushed the opengl-nvidia-driver-info branch from f72b80c to fe7531c Compare January 8, 2025 18:50
@jocado
Copy link
Contributor Author

jocado commented Jan 8, 2025

Thanks @bboozzoo and @zyga - I've made one small update following the comments. PTAL.

@zyga
Copy link
Contributor

zyga commented Jan 8, 2025

I'm familiar with MIG although I do not have the hardware at home.

Thanks for the update, LGTM

@jocado
Copy link
Contributor Author

jocado commented Jan 10, 2025

Hi @bboozzoo - looks like this needs two approvals. Are you able to approve as well so this can be merged ?

@jocado
Copy link
Contributor Author

jocado commented Jan 16, 2025

Hi @zyga and @bboozzoo

Just wondering if we can try and get this merged ? It would be extremely helpful for me if we could get this into the next release.

Thanks!

@zyga zyga requested a review from bboozzoo January 16, 2025 10:53
Copy link
Contributor

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bboozzoo bboozzoo added this to the 2.68 milestone Jan 16, 2025
@bboozzoo
Copy link
Contributor

@jocado can you rebase on top of current master and force push?

Some nvidia hardware companion utilities required access to driver
information in order to operate properly, for example and nvidia-persistenced.
@jocado jocado force-pushed the opengl-nvidia-driver-info branch from fe7531c to cb807c1 Compare January 17, 2025 20:17
@jocado
Copy link
Contributor Author

jocado commented Jan 17, 2025

Hi @bboozzoo - of course. Done!

@bboozzoo
Copy link
Contributor

Unrelated spread failure:

  • google-core:ubuntu-core-18-64:tests/main/security-device-cgroups-helper

@ernestl ernestl changed the title interfaces/opengl: Enable parsing of nvidia driver information files interfaces/builtin/opengl: enable parsing of nvidia driver information files Jan 20, 2025
@ernestl ernestl merged commit a75e772 into canonical:master Jan 20, 2025
44 of 45 checks passed
sespiros added a commit to sespiros/snapd that referenced this pull request Jan 23, 2025
…to snap-integrity-remove-pack

* sespiros/snap-integrity-remove-pack: (86 commits)
  multiple: remove dm-verity support from snap pack
  asserts: snap integrity assertion (canonical#14870)
  overlord: cleanup some old edges
  i/builtin: make auditd-support grant seccomp setpriority (canonical#14940)
  tests: use quotation marks to support directories with spaces (canonical#14948)
  t/m/snap-service-install-mode: fix line being longer than expected
  interfaces/opengl: Enable parsing of nvidia driver information files (canonical#14893)
  i/b/fwupd: allow access to dell bios recovery (canonical#14920)
  tests: divide spread into fundamental/non-fundamental (canonical#14785)
  c/snap-bootstrap: refactor systemd-mount dm-verity/overlayfs options API (canonical#14790)
  o/snapstate: do not restart again for snapd along the undo path inside undoUnlinkCurrentSnap (canonical#14917)
  release: 2.67.1
  tests: fix missing spread failures in PR comments (canonical#14931)
  i/prompting{,requestrules}: merge rules which have identical lifespans (canonical#14757)
  tests: skip apparmor-prompting-integration-tests in armhf (canonical#14919)
  cmd/snap-bootstrap: mount drivers tree if present (canonical#14522)
  i/p/patterns: disallow /./ and /../ in path patterns (canonical#14774)
  osutil/user: look up getent executable in known host directories (canonical#14792)
  overlord: wait for snapd restart after requesting by undo of 'link-snap' (canonical#14850)
  interfaces: update template with new syscalls (canonical#14861)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants